package com.demo.dto;

import java.io.Serializable;

public class BaseResult<T> implements Serializable {

    private static final long serialVersionUID = -4185151304730685014L;

    protected boolean success;

    private T data;
    private Pagination page;
    protected String error;
    /**
     * 处理结果状态码
     * 200表示成功
     */
    protected int code;
    protected int total;

    public BaseResult() {
    }

    public BaseResult(boolean success, String error, int code) {
        this.success = success;
        this.error = error;
        this.code = code;
    }

    public BaseResult(boolean success, String error) {
        this.success = success;
        this.error = error;
    }

    public BaseResult(boolean success, T data) {
        this.success = success;
        this.data = data;
        this.code = 200;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Pagination getPage() {
        return page;
    }

    public void setPage(Pagination page) {
        this.page = page;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    @Override
    public String toString() {
        return "BaseResult [success=" + success + ", data=" + data + ", error="
                + error + "]";
    }

}
